package net.wangds.yunz.auth.comp;

import net.wangds.cache.api.CacheNames;
import net.wangds.validatecode.comp.ValidateCodeComp;
import net.wangds.validatecode.model.VerifyInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Component;

/**
 * 验证码缓存.
 * <p></p>
 *
 * @author 王东石 2020/5/13 21:56.
 */
@Component
public class VerifyCodeCache {

    @Autowired
    private ValidateCodeComp mmCmpVerifyCode;

    @Cacheable(cacheNames = CacheNames.M5, key = "'verify-code-'+#p0")
    public VerifyInfo fetchVerifyInfo(String token){
        VerifyInfo res = mmCmpVerifyCode.drawRandomText(100, 20);
        res.setToken(token);
        return res;
    }

    @CacheEvict(cacheNames = CacheNames.M5, key = "'verify-code-'+#p0")
    public void evictVerifyInfo(String token){
    }



}
